home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Documentation / develop / develop Issue 20 / develop 20 code / QTTextSample / QuicktimeUtils.c < prev    next >
Encoding:
Text File  |  1994-10-14  |  3.6 KB  |  141 lines  |  [TEXT/MPCC]

  1. // Text Media Sample Code - QuickTime routines
  2. //
  3. // This file contains general purpose QuickTime and Utility routines
  4. //
  5. // sample to show how to do searches with text media, and how to use
  6. // a simple text proc to get the text (without the style info) out and
  7. // to display it in a window.
  8. //
  9. // This is something of a work in progress, it contains a few bugs, if you find
  10. // anthing that you feel needs fixing, or explaing, please let me know
  11. // AppleLink: NICKT
  12. //
  13. // Modification History
  14. //
  15. //    10/13/94    nick    First cut - factored code out from other files 
  16. //
  17. //    Copyright:    © 1992-4 by Apple Computer, Inc.
  18.  
  19.  
  20.  
  21. #include "QuickTimeUtils.h"
  22.  
  23. //---------------------------------------------------------------------
  24.  
  25. void     CheckError(OSErr error, Str255 displayString)
  26. {
  27.     // hacky error handler.  It's good to check errors, but this is not
  28.     // really the best way to do it - checking should be more forgiving
  29.     // and the way we are handling errors here is to just quit.
  30.     
  31.     // also this way of doing things uses hardwired strings.  This is bad 
  32.     // because it makes localisation tough to do.
  33.  
  34.     Str255        theErrorAsString ;
  35.     
  36.     if (error == noErr) return;
  37.  
  38.     NumToString( error, theErrorAsString ) ;
  39.     ParamText( displayString, theErrorAsString, "\p", "\p" ) ;
  40.     (void)StopAlert( 130, nil ) ;
  41.  
  42.     ExitToShell();
  43. }
  44.  
  45. //---------------------------------------------------------------------
  46. // Check to see if a window belongs to a desk accessory.
  47.  
  48. Boolean IsDAWindow(WindowPtr window)
  49. {
  50.     if ( window == nil )
  51.         return false;
  52.     else    // DA windows have negative windowKinds
  53.         return ((WindowPeek) window)->windowKind < 0;
  54.  
  55. //---------------------------------------------------------------------
  56.  
  57. Boolean IsQuickTimeInstalled (void) 
  58. {
  59.     short        error;
  60.     long        result;
  61.     
  62.     error = Gestalt (gestaltQuickTime, &result);
  63.     return (error == noErr);
  64. }
  65.  
  66. //---------------------------------------------------------------------
  67.  
  68. OSErr DoPrerollMovie( Movie    aMovie ) 
  69. {
  70.     TimeValue         aTimeValue ;
  71.     TimeValue         movieDur ;
  72.     Fixed             preferredRate ;
  73.     OSErr            theErr = noErr ;
  74.  
  75.     aTimeValue = GetMovieTime(aMovie, nil);
  76.     movieDur = GetMovieDuration(aMovie);
  77.     preferredRate = GetMoviePreferredRate(aMovie);
  78.  
  79.     if (aTimeValue == movieDur) 
  80.         aTimeValue = 0;
  81.         
  82.     theErr = PrerollMovie(aMovie, aTimeValue, preferredRate);
  83.  
  84.     return theErr ;
  85. }
  86.  
  87. //---------------------------------------------------------------------
  88.  
  89. Boolean    IsPointInMovieController( MovieController    aController, WindowPtr whichWindow, Point where)
  90. {
  91.     RgnHandle        rgn ;
  92.     Boolean            result = false ;
  93.     
  94.     rgn = MCGetWindowRgn( aController, whichWindow ) ;
  95.     if( rgn != nil ) {
  96.         result = PtInRgn( where, rgn ) ;
  97.         DisposeRgn( rgn ) ;
  98.     }
  99.     return result ;
  100. }
  101.  
  102. //---------------------------------------------------------------------
  103. // locate the first track in a movie with the supplied type
  104. Track    GetFirstTrackOfType( Movie    aMovie, OSType    trackType )
  105. {
  106.     Track     theTrack  = nil ; 
  107.     OSType     mediaType;
  108.     short    trackCount ;
  109.     short    index ;
  110.     
  111.     trackCount = GetMovieTrackCount(aMovie);
  112.     for ( index=1 ; index <= trackCount ; index++) {
  113.         Track t = GetMovieIndTrack(aMovie, index);
  114.  
  115.         GetMediaHandlerDescription(GetTrackMedia(t), &mediaType, nil, nil);
  116.         if (mediaType == trackType) {
  117.             theTrack = t;
  118.             break;
  119.         }
  120.     }
  121.  
  122.     return theTrack ;
  123.  
  124. }
  125.  
  126. //-----------------------------------------------------------------------
  127. // put up standard file - return true if we choose a movie
  128.  
  129. Boolean    GetAMovieFileSpec (FSSpec *theFile)
  130. {
  131.     SFTypeList                     typeList = {MovieFileType,0,0,0};
  132.     StandardFileReply            reply;
  133.  
  134.     StandardGetFilePreview (nil, 1, typeList, &reply);
  135.     if (reply.sfGood) {
  136.         *theFile = reply.sfFile ;
  137.     }
  138.     return reply.sfGood;
  139. }
  140.